<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body{
            height: 5000px;
        }
        .container{
            border: 5px solid black;
            margin-top: 100px;
            height: 800px;
            /* position: relative; */
        }
        
        .box{
            width: 200px;
            height: 300px;
            /* display: inline-block; */
            float: left;

        }
        #left{
            background: pink;
        }
        #middle{
            background: rebeccapurple;
             /* 定位：position属性允许你对元素进行定位（改变它的位置） */
             /* position: static; */
            /* position: relative;
            left: 30px;
            right: 20px; */
            /* position: absolute;
            left: 30px;
            top: 50px;  */
             /* position: fixed;
             left: 30px;
             top: 50px; */
             position: sticky;
             left: 30px;
             top: 50px;
        }
        #right{
            background: blue;
        }
        .clearfix::after{
            /* ::after :默认行元素，而div是块元素 */
            content:" "; /* 必须和伪类元素搭配使用 */
            clear:both; /*清除浮动  */
            display: block; /*将块元素变成行元素  */
        }
    </style>
</head>
<body>
    <!-- 类添加到父元素身上 -->
    <div class="container clearfix">
         <div class="box" id="left"></div>
         <div class="box" id="middle"></div>
         <div class="box" id="right"></div>
    </div>
</body>
</html>